﻿using System;
using Microsoft.Data.ConnectionUI.MySql.Properties;
using MySql.Data.MySqlClient;
using System.Collections.Generic;
using MySql.Data.VisualStudio;

namespace Microsoft.Data.ConnectionUI.MySql
{
    public class MySql
    {
        private static DataSource _mySqlDataSource;
        public static DataSource MySqlDataSource
        {
            get
            {
                if (_mySqlDataSource == null)
                {
                    _mySqlDataSource = new DataSource("MySqlClient", "MySQL Database");
                    _mySqlDataSource.Providers.Add(MySqlDataProvider);
                    
                }
                return _mySqlDataSource;
            }
        }

        private static DataProvider _mySqlDataProvider;
        public static DataProvider MySqlDataProvider
        {
            get
            {
                if (_mySqlDataProvider == null)
                {
                    var descriptions = new Dictionary<string, string>
                    {
                        {MySqlDataSource.Name, Resources.DataProvider_SqlEverywhere_Description}
                    };

                    var controls = new Dictionary<string, Type>
                    {
                        {string.Empty, typeof (MySqlDataConnectionUI)}
                    };

                    _mySqlDataProvider = new DataProvider(
                        "MySql.Data.MySqlClient",
                        Resources.DataProvider_SqlEverywhere,
                        "MySqlClient",
                        Resources.DataProvider_SqlEverywhere_Description,
                        typeof (MySqlConnection),
                        descriptions,
                        controls,
                        typeof (MySqlConnectionProperties));
                }
                return _mySqlDataProvider;
            }
        }
    }
}
